/*
 * @Author: licongwei
 * @Date: 2022-03-07 16:32:57
 * @Description: 文件描述
 */
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { createRouterGuards } from './guards'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/M1'
  },
  {
    path: '/home',
    component: () => import('@/views/home/home.vue')
  },
  {
    path: '/viewPdf',
    component: () => import('@/views/whiteView/viewPdf.vue')
  },
  {
    path: '/layout',
    component: () => import('@/views/layout/layout.vue'),
    redirect: '/M2',
    children: [
      {
        path: '/M1',
        name: 'M1',
        meta: {
          name: '工作情况'
        },
        component: () => import('@/views/M1/M1.vue')
      },
      {
        path: '/M2',
        name: 'M2',
        meta: {
          name: '价格动态'
        },
        component: () => import('@/views/M2/M2.vue'),
        redirect: '/M2/P1',
        children: [
          {
            path: '/M2/P1',
            name: 'M2P1',
            meta: {
              name: '民生商品'
            },
            component: () => import('@/views/M2/P1/P1.vue')
          },
          {
            path: '/M2/P2',
            name: 'M2P2',
            meta: {
              name: '大宗商品及预测'
            },
            component: () => import('@/views/M2/P2/P2.vue')
          },
          {
            path: '/M2/P3',
            name: 'M2P3',
            meta: {
              name: '价格热点'
            },
            component: () => import('@/views/M2/P3/P3.vue')
          }
        ]
      },
      {
        path: '/M5',
        name: 'M5',
        meta: {
          name: '价格指数'
        },
        component: () => import('@/views/M5/M5.vue')
      },
      {
        path: '/M4',
        name: 'M4',
        meta: {
          name: '价格预警'
        },
        component: () => import('@/views/M4/M4.vue')
      },
      {
        path: '/M3',
        name: 'M3',
        meta: {
          name: '商超对接'
          // name: '待开发'
        },
        component: () => import('@/views/M3/M3.vue'),
        redirect: '/M3/P1',
        children: [
          {
            path: '/M3/P1',
            name: 'M3P1',
            meta: {
              name: '超市概况'
            },
            component: () => import('@/views/M3/P1/P1.vue')
          },
          {
            path: '/M3/P2',
            name: 'M3P2',
            meta: {
              name: '超市商品'
            },
            component: () => import('@/views/M3/P2/P2.vue')
          }
        ]
      }
      // {
      //   path: '/M6',
      //   name: 'M6',
      //   meta: {
      //     name: '价格预测'
      //   },
      //   component: () => import('@/views/M6/M6.vue')
      // },
      // {
      //   path: '/M7',
      //   name: 'M7',
      //   meta: {
      //     name: '价格舆情'
      //   },
      //   component: () => import('@/views/M7/M7.vue')
      // }
    ]
  }

  // {
  //   path: '/test',
  //   name: 'test',
  //   meta: {
  //     name: '测试'
  //   },
  //   component: () => import('@/components/HelloWorld.vue')
  // }
]

const router = createRouter({
  history: createWebHashHistory(
    (window as any).__MICRO_APP_BASE_ROUTE__ || '/'
  ),
  routes
})
createRouterGuards(router)

export default router
